package reader.view.components
{
	import mx.controls.treeClasses.TreeItemRenderer;

	public class LabelTreeItemRenderer extends TreeItemRenderer
	{
		public function LabelTreeItemRenderer()
		{
			super();
			this.buttonMode = true;
		}
		
		override public function set data(value:Object):void
        {
        	super.data = value;
        	if(value)
        	{
				var newBlogs:int = int(XML(value).@newBlogs);
				newBlogs = newBlogs < 0 ? 0 : newBlogs;
				if(newBlogs == 0)
				{
					setStyle("fontWeight", 'normal');
					setStyle("fontSize", '12');
				}
				else
				{
					setStyle("fontWeight", 'bold');
					setStyle("fontSize", '14');
				}
        	}
        	
        }
        
        override protected function updateDisplayList(unscaledWidth:Number,
													  unscaledHeight:Number):void
		{
			super.updateDisplayList(unscaledWidth, unscaledHeight);
			super.label.mouseEnabled = false;
			if(super.data)
			{
				var newBlogs:int = int(XML(super.data).@newBlogs);
				newBlogs = newBlogs < 0 ? 0 : newBlogs;
				if(newBlogs != 0)
				{
					super.label.text = XML(super.data).@label + "(" + (newBlogs <= 1000 ? newBlogs : "1000+") + ")";
					//this.toolTip = super.label.text;
				}
				/* else
					this.toolTip = XML(super.data).@label;	 */
			}
		}

	}
}